'use strict';

angular.module('snPaas').service('appDetailStore',['$http','$q','baseUrl','$timeout',function($http,$q,baseUrl,$timeout){
	var appDetail = function(id){
		var deferred = $q.defer();
		$http.get(baseUrl.ajax+'/rest/app/details',{params:{appId:id}}).success(function(data, status, headers, config){
			deferred.resolve(data);
		});
		return deferred.promise;
	};
	var autoScaling = function(params){

		var deferred = $q.defer();
		$http({
		    method: 'POST',
		    url: baseUrl.ajax+'/rest/app/scaleApp',
		    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
		    data: $.param(params),
		}).success(function (resp) {
			deferred.resolve(resp);
		}).error(function(resp){
			deferred.reject(resp);
		});
		return deferred.promise;

	
	};
	return {
		'detail':appDetail,
		'autoScaling':autoScaling
	};
}]);